#pragma once
#include "Camera.h"
#include "Actor.h"
#include "RenderToTexture.h"
namespace mini
{
	class CRenderViewport : public CActor
	{
	public:
		CRenderViewport();
		virtual ~CRenderViewport();
		bool initViewPortSize(int width, int height);
		void buildCamera(CCamera* pCamera);
		void createBuildCamera(const std::string& cameraName, const CPoint3F& eye, const CPoint3F& lookat);
		bool apply();
		bool beginDraw(DeviceContext* pConetext);
		void endDraw(DeviceContext* pConetext);
		void removeAllRenderNodes();
		void removeRenderNode(CRenderNode* pRenderNode);
		ActorPlaceInfo* addRenderNode(CRenderNode* pRenderNode);
		void addAllScenRenderNode();
		CTexture*	getRenderTexture();
		int getRendererFlag();
		void setRendererFlag(int flag);
		CCamera* getCamera();
		void setCamera(CCamera* pCamear);
		void setMaterial(CMaterialUnit* pMaterialUnit);
		void setMaterial(const std::string& szFile);
		const CMaterialUnit* getMaterialUnit() const;

	protected:
		CMaterialUnit* mpMaterialUnit = nullptr;
		int mRendererFalg = 0;
		CCamera* mpRendererCamera = nullptr;
		CCamera*								mpCamera = nullptr;
		CRenderToTexture*						mpRenderToTexture = nullptr;
		std::set<CRenderNode*>					mRenderNodes;
		std::map<CRenderNode*, ActorPlaceInfo>	mPreviewRenderNodes;
	};
}